package com.hubery.designpattern.design.factory;

import com.hubery.designpattern.enums.PrizeTypeEnum;
import com.hubery.designpattern.design.template.commodity.CommodityService;
import com.hubery.designpattern.design.template.commodity.impl.CouponCommodityService;
import com.hubery.designpattern.design.template.commodity.impl.GoodsCommodityService;
import com.hubery.designpattern.design.template.commodity.impl.PointsCommodityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author lixueyang
 * @since 2023/2/27 20:40
 */
@Slf4j
@Component
public class PrizeFactory {

    public CommodityService getCommodityStrategyService(PrizeTypeEnum prizeTypeEnum) {
        if (PrizeTypeEnum.POINTS.equals(prizeTypeEnum)) {
            return new PointsCommodityService();
        } else if (PrizeTypeEnum.COUPON.equals(prizeTypeEnum)) {
            return new CouponCommodityService();
        } else {
            return new GoodsCommodityService();
        }
    }
}
